<template>
  <div class="concent">
    <div >
      <headers index="3"></headers>
    </div>
    <div style="min-height:80vh ; padding: 0 2vw ; box-sizing: border-box;">
      <el-form style="margin-top: 20px;" :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item label="">
            <el-select v-model="value" @change="selectChange" :placeholder="$t('public.Please_select')">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
         <el-form-item :label="$t('tracking_numbe')">
           <el-input v-model="formInline.tracking_number" :placeholder="$t('tracking_numbe')"></el-input>
         </el-form-item>
         <el-form-item v-if="labelType==1" :label="$t('product_name')">
           <el-input v-model="formInline.name" :placeholder="$t('product_name')"></el-input>
         </el-form-item>
         <el-form-item >
           <el-button  v-if="labelType==1" type="primary" @click="onSubmit">{{$t('query')}}</el-button>
         </el-form-item>
         <el-form-item >
           <el-button  v-if="labelType==2" type="primary" @click="send_out_list()">{{$t('query')}}</el-button>
         </el-form-item>
         <el-form-item v-if="labelType==1">
           <!-- 和包发货 -->
           <el-button type="primary" :disabled="selectList.length>1?false:true" @click="merge">{{$t('Package_delivery')}}</el-button>
         </el-form-item>
         <el-form-item v-if="labelType==2">
           <!-- 待发货订单 -->
           <el-button type="primary" @click="send_out_list('1')">{{$t('Order_to_be_shipped')}}</el-button>
         </el-form-item>
         <el-form-item v-if="labelType==2">
           <!-- 已发货订单 -->
           <el-button type="primary" @click="send_out_list('2')">{{$t('Shipped_order')}}</el-button>
         </el-form-item>
         <el-form-item v-if="labelType==2">
           <!-- 历史订单 -->
           <el-button type="primary" @click="send_out_list('3')">{{$t('order_history')}}</el-button>
         </el-form-item>
       </el-form>
       <div  v-if="labelType==1" >
         <el-checkbox-group v-model="selectList" @change="handleCheckedCitiesChange">
            <el-table :data="list" border style="width: 100%" >
                <el-table-column
                  fixed="left"
                  width="55">
                  <template slot-scope="{row}">
                    <!-- :disabled="row.weight==null" -->
                       <el-checkbox :label="row" >{{''}}</el-checkbox>
                  </template>
                </el-table-column>
              <el-table-column prop="date" label="" align="center" min-width="180">
                <template slot-scope="{row}">
                  {{row.type==1?$t('Modern_Logistics_Development'):$t('Buy_and_distribute_on_behalf_of_others')}}
                </template>
              </el-table-column>
              <el-table-column prop="date" :label="$t('product_image')" align="center" min-width="180">
                <template slot-scope="{row}">

                  <img v-if="row.type==1" :src="imgUrl+row.pic" style="width: 180px;" :alt="$t('Load_Fail')" />
                  <img v-if="row.type==2" :src="imgUrl+row.pic" style="width: 180px;"  :alt="$t('Load_Fail')" />
                </template>
              </el-table-column>
              <!-- 商品名 -->
              <el-table-column prop="name" :label="$t('product_name')" align="center" min-width="180"> </el-table-column>
              <!-- 商品类型 -->
              <el-table-column prop="cname" :label="$t('type_of_merchandise')" align="center" min-width="180"> </el-table-column>
              <!-- 颜色 -->
              <el-table-column prop="colour" :label="$t('colour')" align="center" min-width="180"> </el-table-column>
              <!-- 尺码 -->
              <el-table-column prop="size" :label="$t('Product_Size')" align="center" min-width="180"> </el-table-column>
              <!--  数量-->
              <el-table-column prop="num" :label="$t('amount')" align="center" min-width="180"> </el-table-column>
              <!-- 重量 -->
              <el-table-column prop="weight" :label="$t('weight')" align="center" min-width="180"> </el-table-column>
              <!-- 商品链接 -->
              <el-table-column prop="link" :label="$t('ProductUrl')" align="center" min-width="180"> </el-table-column>
              <!-- 商品价格 -->
              <el-table-column prop="price" :label="$t('commodity_prices')" align="center" min-width="180"> </el-table-column>
              <!-- 订单号码 -->
              <el-table-column prop="order_code" :label="$t('order_number')" align="center" min-width="180"> </el-table-column>
                <!-- 运费 -->
              <el-table-column prop="domestic_freight" :label="$t('carriage')" align="center" min-width="180"> </el-table-column>
              <el-table-column prop="additional_price" :label="$t('extra_charge')" align="center" min-width="180"> </el-table-column>
               <!-- 操作 -->
               <el-table-column
                    fixed="right"
                    :label="$t('operate')"
                    align="center"
                    width="90">
                    <template slot-scope="{row}">
                      <div style="display: flex; flex-direction: column;align-items: center;">
                        <el-button @click="fahuo(row)"   type="text" size="small">{{$t('shipments')}}</el-button>
                        <!-- <el-button  type="text"  size="small">查看</el-button> -->
                        <!-- 编辑 -->
                        <el-button type="text" @click="seeInfo(row)" size="small">{{$t('edit')}}</el-button>
                      </div>
                    </template>
                  </el-table-column>
            </el-table>
         </el-checkbox-group>
         <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="page"
              :page-sizes="[10, 50, 200, 400]"
              :page-size="limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total">
            </el-pagination>
       </div>
       <div class="table_" v-if="labelType==2">
         <el-table :cell-style="cell_style" :data="list2" border stripe style="width: 100%" @selection-change="handleSelectionChange">
           <!-- 包裹类型 -->
           <el-table-column align="center" prop="userName" :label="$t('VRayMtlWrapper')"  min-width="180">
             <template   slot-scope="{row}">
               {{row.order_type==1?$t('common'):$t('common')}}
             </template>
           </el-table-column>
           <!-- 包裹单号 -->
           <el-table-column align="center" prop="Batch_number" :label="$t('parcel_number')"  min-width="180">
             <template   slot-scope="{row}">
               <div class="box_item_box">
                 <div v-for="(item,index) in row.goods" class="box_item">
                   {{item.order_code}}
                 </div>
               </div>
             </template>
           </el-table-column>
           <!-- 商品名称 -->
           <el-table-column align="center" prop="Batch_number" :label="$t('product_name')"  min-width="180">
             <template   slot-scope="{row}">
               <div class="box_item_box">
                 <div v-for="(item,index) in row.goods" class="box_item">
                   {{item.name}}
                 </div>
               </div>
             </template>
           </el-table-column>
           <!-- 商品类型 -->
           <el-table-column align="center" prop="Batch_number" :label="$t('type_of_merchandise')"  min-width="180">
             <template   slot-scope="{row}">
               <div class="box_item_box">
                 <div v-for="(item,index) in row.goods" class="box_item">
                   {{item.cname}}
                 </div>
               </div>
             </template>
           </el-table-column>
           <!-- 颜色 -->
           <el-table-column align="center" prop="Batch_number" :label="$t('colour')"  min-width="180">
             <template   slot-scope="{row}">
               <div class="box_item_box">
                 <div v-for="(item,index) in row.goods" class="box_item">
                   {{item.colour}}
                 </div>
               </div>
             </template>
           </el-table-column>
           <!-- 尺码 -->
           <el-table-column align="center" prop="Batch_number" :label="$t('Product_Size')"  min-width="180">
             <template   slot-scope="{row}">
               <div class="box_item_box">
                 <div v-for="(item,index) in row.goods" class="box_item">
                   {{item.size}}
                 </div>
               </div>
             </template>
           </el-table-column>
           <!-- 数量 -->
           <el-table-column align="center" prop="Batch_number" :label="$t('BNUM')"  min-width="180">
             <template slot-scope="{row}">
               <div class="box_item_box">
                 <div v-for="(item,index) in row.goods" class="box_item">
                   {{item.num}}
                 </div>
               </div>
             </template>
           </el-table-column>
           <!-- 商品价格 -->
           <el-table-column align="center" prop="Batch_number" :label="$t('commodity_prices')"  min-width="180">
             <template slot-scope="{row}">
               <div class="box_item_box">
                 <div v-for="(item,index) in row.goods" class="box_item">
                   {{item.price}}
                 </div>
               </div>
             </template>
           </el-table-column>
           <!-- 重量 -->
           <el-table-column align="center" prop="weight" :label="$t('weight')"  min-width="180"></el-table-column>
          <!-- 运费 -->
          <el-table-column align="center" prop="price" :label="$t('carriage')"  min-width="180"></el-table-column>
          <!-- 附加费用 -->
          <el-table-column align="center" prop="additional_price" :label="$t('extra_charge')"  min-width="180"></el-table-column>
          <!-- 总价 -->
          <el-table-column align="center" prop="money" :label="$t('total_prices')"  min-width="180"></el-table-column>
          <!-- 操作 -->
          <el-table-column
               fixed="right"
               :label="$t('operate')"
               align="center"
               width="90">
               <template slot-scope="{row}">
                 <div style="display: flex; flex-direction: column;align-items: center;">
                   <el-button v-if="row.status == 2" type="text" @click="shureShouHuo(row.id)" size="small">{{$t('confirm_receipt')}}</el-button>
                   <el-button v-if="row.status == 3 && row.comment == 0 " type="text" @click="Gocomment(row)" size="small">{{$t('comment')}}</el-button>
                 </div>
               </template>
             </el-table-column>

         </el-table>
           <!-- <quill-editor  ref="myQuillEditor" v-model="content" :options="editorOption"
               class="my-quill-editor"></quill-editor> -->

         <el-pagination
              @size-change="handleSizeChange1"
              @current-change="handleCurrentChange1"
              :current-page="page1"
              :page-sizes="[10, 50, 200, 400]"
              :page-size="limit1"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total">
            </el-pagination>
       </div>


         <el-dialog :title="$t('Consolidated_shipment')" top="5vh" :visible.sync="dialogVisible" width="70%" :before-close="handleClose">
             <el-form  :model="ruleForm" :rules="rules" ref="ruleForm" label-width="200px" class="demo-ruleForm">
               <el-form-item :label="$t('Logistics_options')" prop="logistics">
                  <el-radio-group v-model="ruleForm.logistics">
                    <!-- 海运cj -->
                    <el-radio :label="1">{{$t('sea_transportation_cj')}}</el-radio>
                    <!-- 航空cj -->
                    <el-radio :label="2">{{$t('aviation_cj')}}</el-radio>
                    <!-- 无验收无开封(海运) -->
                    <el-radio :label="3">{{$t('No_acceptance')}}</el-radio>
                    <!-- 海运CBM(LCL) -->
                    <el-radio :label="4">{{$t('sea_transportation_cmb')}}</el-radio>
                    <!-- 食品(无需个人通关码/普通海关) -->
                    <el-radio :label="5">{{$t('food')}}</el-radio>
                  </el-radio-group>
               </el-form-item>
               <!-- 通关方式 -->
               <el-form-item :label="$t('Customs_clearance_method')" prop="clearance">
                  <el-radio-group v-model="ruleForm.clearance">
                    <!-- 个人通关 -->
                    <el-radio :label="1">{{$t('Personal_clearance')}}</el-radio>
                    <!-- 企业通关 -->
                    <el-radio :label="2">{{$t('Enterprise_clearance')}}</el-radio>
                  </el-radio-group>
               </el-form-item>
               <!-- 收货人姓名 -->
               <el-form-item v-if="ruleForm.clearance==1" :label="$t('Consignee_Name')" prop="name">
                 <div>
                   <el-input class="input_class" v-model="ruleForm.name" :placeholder="$t('name_h')"></el-input>
                 </div>
                 <div>
                   <el-input class="input_class" v-model="ruleForm.en_name" :placeholder="$t('name_e')"></el-input>
                 </div>
               </el-form-item>
               <!-- 企业名 -->
               <el-form-item v-if="ruleForm.clearance==2" :label="$t('corporation_name')" prop="company_name">
                 <div>
                   <el-input class="input_class" v-model="ruleForm.company_name" :placeholder="$t('corporation_name_h')"></el-input>
                 </div>
                 <div>
                   <el-input class="input_class" v-model="ruleForm.en_company_name" :placeholder="$t('corporation_name_e')"></el-input>
                 </div>
               </el-form-item>
               <!-- 通关编码方式 -->
               <el-form-item :label="$t('Clearance_code_method')" prop="directory">
                  <el-radio-group v-model="ruleForm.directory">
                    <!-- 个人目录通关(空运) -->
                    <el-radio v-if="ruleForm.clearance==1" :label="1">{{$t('Personal_directory_customs_clearance_air_freight')}}</el-radio>
                    <!-- 个人简易通关(空运) -->
                    <el-radio v-if="ruleForm.clearance==1" :label="2">{{$t('Personal_simple_customs_clearance_air_freight')}}</el-radio>
                    <!-- 企业目录通关(空运) -->
                    <el-radio v-if="ruleForm.clearance==2" :label="3">{{$t('Enterprise_directory_customs_clearance_air_freight')}}</el-radio>
                    <!-- 企业简易通关(空运) -->
                    <el-radio v-if="ruleForm.clearance==2" :label="4">{{$t('Easy_customs_clearance_air_freight')}}</el-radio>
                    <!-- 目录通关(海运) -->
                    <el-radio v-if="ruleForm.clearance==2" :label="5">{{$t('Catalog_clearance_sea_freight')}}</el-radio>
                    <!-- 简易通关(海运) -->
                    <el-radio v-if="ruleForm.clearance==2" :label="6">{{$t('Easy_customs_clearance_sea_freight')}}</el-radio>
                  </el-radio-group>
               </el-form-item>
               <el-form-item :label="$t('Clearance_code_check')" prop="clearance_code">
                 <el-input class="input_class" v-model="ruleForm.clearance_code" :placeholder="$t('Clearance_code_check')"></el-input>
                 <el-button type="primary" :loading="checkCodeLoading" @click="checkCode(ruleForm.clearance_code)" style="margin-left: 20px;">{{$t('checkout')}}</el-button>
               </el-form-item>
               <el-form-item  v-if="ruleForm.clearance==2" :label="$t('Business_license_upload')" prop="license">
                 <el-upload
                  action=""
                   class="upload-demo"
                   :before-upload="fileChange"
                   :show-file-list="false"
                   list-type="picture">
                   <!-- 点击上传 -->
                   <el-button size="small" type="primary">{{$t('Click_to_upload')}}</el-button>
                   <!-- 只能上传jpg/png/pdf文件 -->
                   <div slot="tip" class="el-upload__tip">{{$t('Upload_files_only')}}</div>
                 </el-upload>
                 <img v-if="ruleForm.license && ruleForm.file.type != 'application/pdf'"  :src="imgUrl+ruleForm.license" width="100px" alt="" />

                 <el-button v-if="ruleForm.license && ruleForm.file.type =='application/pdf'"  size="small" type="text">
                   <!--pdf文件 点击查看 -->
                   {{$t('pdf_file')}}  <a :href="imgUrl+ruleForm.license" target="_blank">{{$t('click_to_view')}}</a>

                   </el-button>
               </el-form-item>
               <!-- 手机号 -->
               <el-form-item :label="$t('cell_phone_number')" prop="mobile">
                 <el-input class="input_class" type="text" maxlength="11" @input="(e)=>{ruleForm.mobile = e.replace(/[^0-9]/g,'')}" v-model="ruleForm.mobile" :placeholder="$t('cell_phone_number')"></el-input>
               </el-form-item>
               <!-- 地址 -->
               <el-form-item :label="$t('site')" prop="address">
                 <el-input class="input_class" v-model="ruleForm.address" :placeholder="$t('site')"></el-input>
               </el-form-item>
               <!-- 详细地址 -->
               <el-form-item :label="$t('detailed_address')" prop="address2">
                 <el-input class="input_class" v-model="ruleForm.address2" :placeholder="$t('detailed_address')"></el-input>
               </el-form-item>
               <!-- 邮政编码 -->
               <el-form-item :label="$t('postal_code')" prop="zip_code">
                 <el-input class="input_class" v-model="ruleForm.zip_code"  :placeholder="$t('postal_code')"></el-input>
                 <el-button type="primary" style="margin-left: 20px;"> <a href="https://www.naver.com" style="color: #fff;" target="_blank" >{{$t('Zip_code_search')}}</a> </el-button>
               </el-form-item>
               <el-form-item :label="$t('Delivery_requirement')" prop="ask">
                 <el-input class="input_class" v-model="ruleForm.ask" :placeholder="$t('Delivery_requirement')"></el-input>
               </el-form-item>
               <div style="width: 100%;display: flex;justify-content: flex-end;">
                 <el-button type="primary" :loading="btn1" @click="submitFrom('ruleForm')"   style="margin-left: 20px;">{{$t('submit')}}</el-button>
               </div>

             </el-form>
         </el-dialog>
        <!-- 评论入口 -->
        <el-dialog
          :title="$t('comment')"
          :visible.sync="commentShow"
          width="50%"
          :before-close="commentClose">
          <div>
              <el-form :rules="commentrules" ref="commentform" :model="commentform" label-width="80px">
                <el-form-item :label="$t('title')" prop="name">
                  <el-input v-model="commentform.name"></el-input>
                </el-form-item>
                <el-form-item :label="$t('Content')" prop="content">
                  <el-input v-model="commentform.content"></el-input>
                </el-form-item>
                <el-form-item :label="$t('print')" prop="pic">
                  <el-upload
                    :http-request="upload"
                    action="#"
                    :disabled="imgList.length>0"
                    :limit="1"
                    :file-list="imgList"
                    list-type="picture-card"
                    :before-upload="picChange"
                    >
                    <i class="el-icon-plus"></i>
                     <div slot="file" slot-scope="{file}">
                          <img
                            class="el-upload-list__item-thumbnail"
                            :src="file.url" alt=""
                          >
                          <span class="el-upload-list__item-actions">
                            <span
                              class="el-upload-list__item-delete"
                              @click="handleRemove(file)"
                            >
                              <i class="el-icon-delete"></i>
                            </span>
                          </span>
                        </div>
                  </el-upload>
                </el-form-item>
              </el-form>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button @click="commentShow = false">{{$t('cancel')}}</el-button>
            <el-button type="primary" :loading="commentLoading" @click="onSubmitcomment">{{$t('affirm')}}</el-button>
          </span>
        </el-dialog>
    </div>

  </div>
</template>
<script>
  import {
  order_list,
  checkCode,
  send_out_goods,
  send_out_list,
  order_status,
  user_comment
  } from '@/utils/wqzApi'
  import exoprt_file from '@/utils/expor_file' // 导出excel文件
 import headers from "@/components/header"
 import footers from "@/components/footers"
 export default {
     components:{
       footers,
       headers,
     },
      data() {
        return {
          commentLoading:false,
          commentrules:{
            name: [
              { required: true, message:this.$t('public.Please_select'), trigger: 'blur' },
            ],
            content: [
              { required: true, message:this.$t('public.Please_select'), trigger: 'blur' },
            ],
            pic: [
              { required: true, message:this.$t('public.Please_select'), trigger: ['blur' , 'change'] },
            ],
          },
          commentID:'',//评论的订单id
          imgList:[

          ],//图片列表
          commentform:{
            'order_id':'',
            "name":'',
            "type": 0, //0默认1追评
            "content": '',
            "pic": "", //图片
          }, //评论提交表单
          ber_type:'2',
          commentShow:false,
          options:[
            {value: '1',label: this.$t('Inventory_control_list')},
            {value: '2',label: this.$t('Order_status_list')},
          ],
          value:'1',
          cell_style:{
            'flex-direction': 'column',
            'height':'auto',
            'position':'relative',
            'height':'100%',
            'padding':0,
          },
          btn1:false,
          labelType:1,
          checkCodeLoading:false,
          rules:{
            logistics: [
              { required: true, message:this.$t('public.Please_select'), trigger: 'blur' },
            ],
            clearance:[
              { required: true, message:this.$t('public.Please_select'), trigger: 'blur' },
            ],
            directory:[
              { required: true, message:this.$t('public.Please_select'), trigger: 'blur' },
            ],
            name: [
               {required: true, validator: (rule, value, callback)=>{
                 if (this.ruleForm.name === '') {
                   callback(new Error(this.$t('public.Please_enter_your_name_h')));
                   return
                 }
                 if (this.ruleForm.en_name === '') {
                   callback(new Error(this.$t('public.Please_enter_your_name_e')));
                   return
                 }
                callback();
               }, trigger: 'blur' }
            ],
            company_name:[
               {required: true, validator: (rule, value, callback)=>{
                 if (this.ruleForm.company_name === '') {
                   callback(new Error(this.$t('public.Please_enter_your_company_name_h')));
                   return
                 }
                 if (this.ruleForm.en_company_name === '') {
                   callback(new Error(this.$t('public.Please_enter_your_company_name_e')));
                   return
                 }
                callback();
               }, trigger: 'blur' }
            ],
            license:[
               {required: true, validator: (rule, value, callback)=>{
                 if (this.ruleForm.license === '') {
                   callback(new Error(this.$t('public.Please_upload_your_business_license')));
                   return
                 }
                callback();
               }, trigger: 'blur' }
            ],
            clearance_code:[
              { required: true, message:this.$t('public.Please_enter'), trigger: 'blur' },
            ],
            zip_code:[
              { required: true, message:this.$t('public.Please_enter'), trigger: 'blur' },
            ],
            mobile:[
              { required: true, message:this.$t('public.Please_enter'), trigger: 'blur' },
            ],
            address:[
              { required: true, message:this.$t('public.Please_enter'), trigger: 'blur' },
            ],
            address2:[
              { required: true, message:this.$t('public.Please_enter'), trigger: 'blur' },
            ],
          },
          ruleForm:{
            id:'',
          'order_type':2,
           "type": 1, //1 普通发货 2合箱发货
           "name": "", //收件人
           "company_name": "", //企业名（2选1，选企业走企业名，选个人走个人名）
           "logistics": 1, //1海运 2航空 3无验收，无开封 4海运CBM 5食品EMS
           "clearance": 1, //1个人通关 2海运通关
           "clearance_code": "", //通关编码
           "license": "", //营业执照图
           "mobile": "", //手机号
           "address": "", //地址
           "address2": "", //详细地址
           "zip_code": "", //邮编
           "ask": "", //送货要求
           "en_name": "", //英文收件人名
           "en_company_name": "", //英文企业收件人名
           "directory": 1 ,//目录空运(个人目录是1/个人简易是3/企业目录是2/企业简易是3),海运(目录通关：1 /简易通关：3)
           'file':null,
          },
          dialogVisible:false,
          imgUrl:process.env.VUE_APP_BASE_imgUrl,
          page:1,
          limit:10,
          page1:1,
          limit1:10,
          formInline:{
            name:'',
            tracking_number:''
          },
          list:[],
          list2:[],//已发货列表
          total:0,
          selectList:[]
        }
      },
      mounted() {
        this.order_list()

      },
      methods:{
        onSubmitcomment(){
          // 提交评论接口
            var data = {
              ...this.commentform
            }
            this.commentLoading = true
          this.$refs.commentform.validate((valid) => {
            if (valid) {
              console.log(data)
              user_comment(data).then(res=>{
                this.commentLoading = false
                this.$message({
                  type:'success',
                  message:this.$t('operate_successfully')
                })
                this.commentShow = false
                this.send_out_list()
              }).catch(err=>{
                this.commentLoading = false
              })
            } else {
              console.log('error submit!!');
              this.commentLoading = false
              return false;
            }
          });

            console.log(data)
        },
        // 评论图片上传接口
        upload(file){
          file = file.file
           // this.ruleForm.file = file
           let data = new FormData()
           data.append('file', file)
           exoprt_file('index.php/index/index/file'  , data).then(res=>{
             console.log('chenggon1' , res)
             this.commentform.pic = process.env.VUE_APP_BASE_imgUrl+res
             this.imgList = [{url:process.env.VUE_APP_BASE_imgUrl+res}]
          })
        },
        picChange(file){
          // 评论图片文件验证 png jpg jpeg
          if(file.type == 'image/png' ||  file.type == 'image/jpeg' ||  file.type == 'image/jpg'){

          }else{
              this.$message({
                type:'error',
                message:this.$t('public.Upload_format_mismatch')
              })
              return false
          }
        },
        handleRemove(file){
          console.log('删除')
          this.imgList = []
        },
        commentClose(){
          this.commentShow = !this.commentShow
        },
        Gocomment({id}){
          this.commentform={
            'order_id':'',
            "name":'',
            "type": 0, //0默认1追评
            "content": '',
            "pic": "", //图片
          }
          this.commentform.order_id= id

          this.commentShow = true
        },
        shureShouHuo(id){
          // 确认收货
          var data = {
            id:id,
            status:3
          }
          // 确认收货提示框
          this.$confirm(this.$t('Acknowledge_receipt_of_goods')+'?', this.$t('reminder'), {
            confirmButtonText: this.$t('affirm'),
            cancelButtonText: this.$t('cancel'),
            type: 'warning'
          }).then(() => {
            order_status(data).then(res=>{
              this.$message({
                type: 'success',
                message: this.$t('public.Operation_successful')
              });
               this.send_out_list()
            }).catch(err=>{

            })
          }).catch(() => {

          });

        },
        selectChange(e){
          console.log(e)
          this.ber_type = e
          if(e == 1){
            this.order_list()
          }else{
            this.send_out_list("1")
          }
        },
        send_out_list(type=''){
          // 查询历史订单
          if(type!=''){
            this.ber_type = type
          }
          var data = {
          "page": this.page1, //页码
          "limit": this.limit1, //条数
          "status": this.ber_type, //1待发货 2已发货 3已完成
          "code": this.formInline.tracking_number //包裹单号
          }
         this.labelType = 2
          send_out_list(data).then(res=>{
              console.log(res , '返回信息')
              this.list2 = res.data.list
              this.total = res.data.count
          })
        },
        handleSizeChange(e){
          this.limit = e
          this.order_list()
        },
        handleCurrentChange(e){
          this.page = e
          this.order_list()
        },
        handleSizeChange1(e){
          this.limit1= e
          this.send_out_list()
        },
        handleCurrentChange1(e){
          this.page1 = e
          this.send_out_list()
        },
        fahuo(row){
          var data = {
            "id": row.order_id, //order_id多个逗号分隔，单个普通发货只传一个
            "order_type": 1, //1 普通发货 2合箱发货
            "type": row.type, //1代发 2代发代买
          }
          send_out_goods(data).then(res=>{
            this.$message({
              type:'success',
              message:this.$t('operate_successfully')
            })
            this.order_list()
          }).catch(err=>{
          })
        },
        handleCheckedCitiesChange(e){
          console.log(e)
        },
        submitFrom(ref){
          this.btn1 = true
                  this.$refs[ref].validate((valid) => {
                    if (valid) {
                        this.btn1 = false
                        var data = {
                            ...this.ruleForm
                        }
                        delete data.file
                        send_out_goods(data).then(res=>{
                          this.$message({
                            type:'success',
                            message:this.$t('operate_successfully')
                          })
                          this.dialogVisible = !this.dialogVisible
                          this.order_list()
                        }).catch(err=>{
                        })
                    } else {
                      this.btn1 = false
                      return false;

                    }
                  });
        },
        handleClose(){
          this.dialogVisible = !this.dialogVisible
        },
        merge(){
          // 合并发货
          if(this.selectList.length==0){
            this.$message({
              type:'error',
              message:this.$t('Please_select_the_order_you_want_to_merge')
            })
            return
          }
          var ids = []
          this.selectList.forEach((item,index)=>{
            ids.push(item.order_id)
          })
          this.ruleForm.id = ids.join(',')
          this.handleClose()
        },
        handleSelectionChange(e){
          this.selectList = e
        },
        onSubmit(){
          this.page = 1
          this.order_list()
        },
        seeInfo(row){
          if(row.type == 1){
            this.$router.push({ path: '/agency_purchase', query: { id: row.order_id?row.order_id:row.orderId}})
            setTimeout(()=>{
              location.reload()
            },20)
          }
          if(row.type == 2){
            // localStorage.setItem('chooseHeadrIndex' , 1)
            this.$router.push({ path: '/Purchase_on_behalf', query: { id: row.order_id?row.order_id:row.orderId}})
            setTimeout(()=>{
              location.reload()
            },20)
          }
        },
         checkCode(code){
          // 通关码教案
          if(!code){
            this.$message({
              type:'error',
              message:this.$t('Please_enter_the_clearance_code')
            })
            return
          }
          this.checkCodeLoading = true
          var data = {
            clearance_code:code
          }
          checkCode(data).then(res=>{
            this.$message({
              type:'success',
              message:this.$t('The_clearance_code_is_verified_successfully')
            })
            this.checkCodeLoading = false
          }).catch(err=>{
            this.checkCodeLoading = false
          })
        },
        fileChange(file) {
          if(file.type == 'image/png' || file.type == 'application/pdf' || file.type == 'image/jpeg' ||  file.type == 'image/jpg'){
             this.ruleForm.file = file
             let data = new FormData()
             data.append('file', file)
             exoprt_file('index.php/index/index/file'  , data).then(res=>{
               this.ruleForm.license = res
            })
          }else{
            this.$message({
              type:'error',
              message:this.$t('public.Upload_format_mismatch')
            })
          }
          return


        },
        order_list(){
          this.labelType = 1
          var data = {
            "page": this.page, //页码
            "limit": this.limit, //条数
            "name": this.formInline.name, //商品名
            "tracking_number": this.formInline.tracking_number //快递单号
          }
          order_list(data).then(res=>{
            console.log(res)
            this.list = res.data.list
            this.total = res.data.count
          })
        }
      }

  }
</script>

<style scoped lang="scss">
  .concent{
    width: 100%;
    // padding: 1vw;
    // box-sizing: border-box;
  }

.table_ .cell {
  padding: 0 !important;
  box-sizing: border-box;
}
.box_item_box{
  flex: 1;

}
.box_item{
  border-bottom: 1px solid  #e6ebf5;
  height: 80px !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
